<template>
<el-dialog
    v-model="dialogVisible"
    title="Tips"
    width="500"
    :before-close="handleClose"
  >
    <span>你的成绩为：{{score}}</span>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogVisible = false&&goHome">回到主页</el-button>
        <el-button type="primary" @click="dialogVisible = false&&handleClose">
          查看答案
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup lang='ts'>
import { ref } from 'vue'
import { ElMessageBox } from 'element-plus'
import router from '@/router';
defineProps({
  score: {
    type: Number,
    required: true
  }
})

const dialogVisible = ref(false)
const goHome = () => {
  router.push('/home')
}
const handleClose = (done: () => void) => {
  ElMessageBox.confirm('Are you sure to close this dialog?')
    .then(() => {
      done()
    })
    .catch(() => {
      // catch error
    })
}
</script>

<style scoped>
</style>